package bean;

import exception.BelowZeroException;
import exception.BelowZeroRuntimeException;

public class Student {
    int id;

    public void regist(int id) {
        if (id > 0) {
            this.id = id;
        } else {
//            System.out.println("输入的id非法。");
            // 手动抛出异常
            throw new BelowZeroRuntimeException("输入的ID非法。");
        }
    }

    public void regist2(int id) throws BelowZeroException {
        if (id > 0) {
            this.id = id;
        } else {
//            System.out.println("输入的id非法。");
            // 手动抛出异常
            throw new BelowZeroException("输入的ID非法。");
        }
    }
}
